<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Hello World</title>
    <script src="../vue.js"></script>
  </head>
  <body>
    <div id="root">
      <!-- <child-one v-if="type === 'child-one'"></child-one>
      <child-two v-if="type === 'child-two'"></child-two> -->
      <component :is="type"></component>
      <button @click="handleClick">toggle</button>
    </div>
    <script>
      Vue.component('child-one', {
        template: '<div v-once>child-one</div>'
      })
      Vue.component('child-two', {
        template: '<div v-once>child-two</div>'
      })

      var vm = new Vue({
        el: '#root',
        data:{
          type: 'child-one'
        },
        methods: {
          handleClick() {
            this.type = this.type === 'child-one' ? 'child-two' : 'child-one'
          }
        }
      })
    </script>
  </body>
</html>
